/**
@C++ Standard: 11
@Copyright:Copyright (c) 2019 Harold Hu. All rights reserved.
@Author: Created by Harold Hu with CLion on 2019/1/14 14:13.
@File Name: testMatrix.cpp
@Description: test Matrix
*/
#define TEST_MATRIX 1
#if TEST_MATRIX
#include "../../../TestFramework/HaroldDebug.h"

#if TEST_TYPE == TEST_GTEST

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "glog/logging.h"

namespace {

#include "../../../Inc/Matrix.h"
#include "../../../Inc/ScopeGuard.h"
	
	
	struct tT
	{
	public:
		tT() : _numA(1), _numB(2), _numC(3)
		{
		}
		
		tT(const int& numA, const int& numB, const int& numC) : _numA(numA), _numB(numB), _numC(numC)
		{
		}
		
		tT(const tT&) = default;
		
		tT& operator=(const tT&) = default;
		
		bool operator==(const tT& rhs) const
		{
			if (this == &rhs)
			{
				return true;
			}
			return (_numA == rhs._numA) && (_numB == rhs._numB) && (_numC == rhs._numC);
		}
		
		friend std::ostream& operator<<(std::ostream& os, const tT& type)
		{
			os << "_numA: " << type._numA << " _numB: " << type._numB << " _numC: " << type._numC;
			return os;
		}
		
		int _numA;
		int _numB;
		int _numC;
		~tT() = default;
	};
	
	TEST(TestMatrix, Test_constructor)
	{
		cout << endl;
		Matrix<tT> testMatrix1 = Matrix<tT>(1, 2);
		cout << testMatrix1 << endl;
		EXPECT_EQ(testMatrix1.getPtr(0, 0)->_numC, tT()._numC);
		EXPECT_EQ(*(testMatrix1.getPtr(0, 0)), tT());
		Matrix<tT> testMatrix2 = Matrix<tT>(1, 2, 4, 4, 4);
		cout << testMatrix2 << endl;
		Matrix<tT> testMatrix22 = Matrix<tT>(2, 2, 4, 4, 4);
		cout << testMatrix22 << endl;
		EXPECT_EQ(testMatrix2.getPtr(0, 0)->_numC, tT(4, 4, 4)._numC);
		cout << __FILE__ << " " << __LINE__ << " " << testMatrix1.getData()[0] << endl;
		cout << __FILE__ << " " << __LINE__ << " " << testMatrix2.getData()[1] << endl;
		testMatrix2 = testMatrix1;
		cout << __FILE__ << " " << __LINE__ << " " << testMatrix2.getData()[1] << endl;
		Matrix<tT> testMatrix3(testMatrix2);
		cout << __FILE__ << " " << __LINE__ << " " << testMatrix3.getData()[0] << endl;
		auto matrixPtr = new Matrix<int>(2,2);
		auto guard = createGuard([](decltype(matrixPtr) ptr){
			delete ptr;
		}, matrixPtr);
		cout << matrixPtr->getData() << endl;
	}
}
#endif
#endif